package com.heyou.ticket.config;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeCloudStore;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeStoreOptions;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HeyouAgentConfig {

    @Value("${spring.ai.dashscope.api-key}")
    private String apiKey;

    @Bean
    public VectorStore vectorStore() {
        return new DashScopeCloudStore(new DashScopeApi(apiKey), new DashScopeStoreOptions("heyou_ticket_index"));
    }

    @Bean
    public ChatMemory chatMemory() {
        // 暂时使用内存存储，后续换成redis
        return new InMemoryChatMemory();
    }
}
